﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class SpritePosToSortOrder : MonoBehaviour
{
	public int _OrderOfs = 0;
	private SpriteRenderer _Sprite;
	private Transform _Transform;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
		if(_Sprite == null)
			_Sprite = GetComponent<SpriteRenderer>();
		
		_Sprite.sortingOrder = (int)(transform.position.y * -10f) + _OrderOfs;
    }

	void OnValidate()
	{
		
	}
}
